package com.aaa.ssm.controller;

import com.aaa.ssm.entity.TptFconTact;
import com.aaa.ssm.service.TptFconTactService;
import com.aaa.ssm.util.Page;
import com.aaa.ssm.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

//常用联系人
@RestController
@RequestMapping("tpt")
public class TptFconTactController extends BaseController{
    @Resource
    private TptFconTactService  tptFconTactService;

    /**根据id获取关联用户id
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result getList(@PathVariable Integer id){
        List<TptFconTact> list = tptFconTactService.getList(id);
        System.out.println(list);
        return success(list);
    }

    /**
     * 分页查询
     * @param tptFconTactPage
     * @return
     */
    @RequestMapping("queryPage")
    public Result queryPage(@RequestBody Page<TptFconTact> tptFconTactPage){
       return   success(tptFconTactService.queryPage(tptFconTactPage));
    }

    /**
     * 根据用户id分页查询
     * @return
     */
    @RequestMapping("queryPageBy")
    public Result queryPageBy(){
        return success(tptFconTactService.queryPageId());
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @GetMapping("queryById")
    public Result queryById(Integer id){
        return   success(tptFconTactService.queryById(id));
    }

    /**
     * 添加
     * @param tptFconTact
     * @return
     */
    @RequestMapping("tptAdd")
    public Result outAdd(@RequestBody TptFconTact tptFconTact){
        return  success(tptFconTactService.TptAdd(tptFconTact));
    }

    /**
     * 修改
     * @param tptFconTact
     * @return
     */
    @PostMapping("tptUpdate")
    public Result tptUodate(@RequestBody TptFconTact tptFconTact){
        return   success(tptFconTactService.TptUpdate(tptFconTact));
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping("tptDelete/{id}")
    public Result tptDelete(@PathVariable("id") Integer id){
        return success(tptFconTactService.TptDelete(id));
    }
}
